from django.conf import settings

from apps.app_tx_meeting.managers import tx_meeting_configs


def set_tx_meeting_configs(
        reserve_room_advance_minutes: int = 30,
        meeting_after_reserve_minutes: int = 60,
        default_advance_notice_minutes: int = 15,
):
    tx_settings = settings.TEST_CASE.get('TX_MEETING', {})
    tx_meeting_configs.set(tx_meeting_configs.ConfigName.TX_APP_ID.value, value=tx_settings.get('app_id'))
    tx_meeting_configs.set(tx_meeting_configs.ConfigName.TX_SDK_ID.value, value=tx_settings.get('sdk_id'))
    tx_meeting_configs.set(tx_meeting_configs.ConfigName.TX_SECRET_ID.value, value=tx_settings.get('secret_id'))
    tx_meeting_configs.set(tx_meeting_configs.ConfigName.TX_SECRET_KEY.value, value=tx_settings.get('secret_key'))
    tx_meeting_configs.set(tx_meeting_configs.ConfigName.TX_OPERATOR_ID.value, value=tx_settings.get('operator_id'))

    tx_meeting_configs.set(
        tx_meeting_configs.ConfigName.RESERVE_ROOM_ADVANCE_MINUTTES.value, value=str(reserve_room_advance_minutes))
    tx_meeting_configs.set(
        tx_meeting_configs.ConfigName.MEETING_AFTER_RESERVE_MINUTES.value, value=str(meeting_after_reserve_minutes))
    tx_meeting_configs.set(
        tx_meeting_configs.ConfigName.DEFAULT_ADVANCE_NOATICE_MINUTES.value, value=str(default_advance_notice_minutes))

    tx_meeting_configs.clear_cache()


def set_tx_meeting_email_config(
        host: str, port: int, host_user: str, host_password: str, use_ssl: bool = False, use_tls: bool = False
):
    tx_meeting_configs.set(tx_meeting_configs.ConfigName.EMAIL_HOST.value, host)
    tx_meeting_configs.set(tx_meeting_configs.ConfigName.EMAIL_PORT.value, str(port))
    tx_meeting_configs.set(tx_meeting_configs.ConfigName.EMAIL_HOST_USER.value, host_user)
    tx_meeting_configs.set(tx_meeting_configs.ConfigName.EMAIL_HOST_PASSWORD.value, host_password)
    tx_meeting_configs.set(tx_meeting_configs.ConfigName.EMAIL_USE_SSL.value, 'true' if use_ssl else 'false')
    tx_meeting_configs.set(tx_meeting_configs.ConfigName.EMAIL_USE_TLS.value, 'true' if use_tls else 'false')
